package com.reform.controller.project;


import com.reform.res.Result;
import com.reform.res.ResultCode;
import com.reform.service.IViewProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.sql.SQLException;

/**
 * <p>
 * VIEW 前端控制器
 * </p>
 *
 * @author mortale
 * @since 2021-07-21
 */
@Api(tags = "ViewProjectController")
@RestController
@RequestMapping("/viewProject")
public class ViewProjectController {

    @Autowired
    IViewProjectService viewProjectService;

    @ApiOperation(value = "获取所有项目", notes = "获取所有项目")
    @GetMapping("/getAllProject")
    @ApiImplicitParams({
    })
    public Result getAllProject() throws SQLException {
        return viewProjectService.getAllProject();
    }


    @ApiOperation(value = "获取目标批次下的所有项目", notes = "获取目标批次下的所有项目")
    @PostMapping("/getProjectByBatchId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "batchId", value = "批次ID", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result getProjectByBatchId(String batchId) throws SQLException {
        return viewProjectService.getProjectByBatchId(batchId);
    }

    @ApiOperation(value = "根据项目id获取项目", notes = "根据项目id获取项目")
    @PostMapping("/getProjectById")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "proId", value = "项目ID", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result getProjectById(String proId) throws SQLException {
        return viewProjectService.getProjectById(proId);
    }

    @ApiOperation(value = "获取当前教师最近一次申报的项目信息", notes = "获取当前教师最近一次申报的项目信息")
    @PostMapping("/getRecentProject")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "batch_id", value = "批次id", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result getRecentProject(String batch_id, HttpServletRequest request) throws SQLException {
        return viewProjectService.getRecentProject(batch_id, request);
    }

    @ApiOperation(value = "根据批次id获取简单项目信息", notes = "根据批次id获取简单项目信息")
    @PostMapping("/getSimplifyProjectByBatchId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "batch_id", value = "批次id", paramType = "query", dataTypeClass = String.class, required = true),
            @ApiImplicitParam(name = "pro_approvals", value = "项目状态", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result getSimplifyProjectByBatchId(String batch_id,String pro_approvals) throws SQLException {
        return viewProjectService.getSimplifyProjectByBatchId(batch_id,pro_approvals);
    }

    @ApiOperation(value = "根据阶段id获取简单项目信息", notes = "根据阶段id获取简单项目信息")
    @PostMapping("/getSimplifyProjectByPhaseId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phaseId", value = "阶段id", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result getSimplifyProjectByPhaseId(String phaseId) throws SQLException {
        return viewProjectService.getSimplifyProjectByPhaseId(phaseId);
    }

    @ApiOperation(value = "获取所有延期简单项目信息", notes = "获取所有延期简单项目信息")
    @GetMapping("/getAllDelayProject")
    public Result getAllDelayProject() throws SQLException {
        return viewProjectService.getAllDelayProject();
    }

    @ApiOperation(value = "根据延期编号获取所有延期简单项目信息", notes = "根据延期编号获取所有延期简单项目信息")
    @PostMapping("/getAllDelayProjectById")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "proApprovals", value = "项目状态", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result getAllDelayProjectById(String proApprovals) throws SQLException {
        return viewProjectService.getAllDelayProjectById(proApprovals);
    }

}
